﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using System.Xml;
using System.Diagnostics;
using System.Xml.Linq;

namespace TestPlanWordWriter.Common.Word
{
    public class OpcStreamBuilder
    {
        private string _sourceOpenXml;
        public OpcStreamBuilder(string sourceOpenXml)
        {
            _sourceOpenXml = sourceOpenXml;
        }

        public void BuildOpenDocumentStream(Stream opcStream)
        {
            using (MemoryStream documentStream = new MemoryStream(Encoding.UTF8.GetBytes(_sourceOpenXml)))
            {
                documentStream.Seek(0, SeekOrigin.Begin);
                XDocument document = XDocument.Load(documentStream);

                FlatOpcConverter.FlatToOpc(document, "", opcStream);
                opcStream.Seek(0, SeekOrigin.Begin);
            }
        }
    }
}
